package com.example.musicapi.dao;

import com.example.musicapi.entity.News;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface NewsDao extends JpaRepository<News, String> {

    News findDataById(String id);

    Page<News> findAll(Pageable pageable);

    Page<News> findAllById(Pageable pageable, String id);


    //  根据 key 进行模糊查询的分页方法
    @Query("SELECT n FROM News n WHERE n.title LIKE %:key%")
    Page<News> findBySearch( @Param("key")  String key, Pageable pageable);

}
